package com.lwj.liwanjia.presenter;

import com.lwj.liwanjia.bean.PromotionMoreBean;
import com.lwj.liwanjia.impl.PromotionMoreView;
import com.lwj.liwanjia.model.PromotionMoreModel;

import rx.Subscriber;

/**
 * Created by Administrator on 2017/9/25.
 */

public class PromotionMorePresenter {
    private PromotionMoreView promotionMoreView;
    private PromotionMoreModel promotionMoreModel;

    public PromotionMorePresenter(PromotionMoreView promotionMoreView) {
        this.promotionMoreView = promotionMoreView;
        promotionMoreModel = new PromotionMoreModel();
    }

    public void getPromotionMore(int page) {
        if (promotionMoreView != null) {
            promotionMoreModel.getPromotionMore(page, new Subscriber<PromotionMoreBean>() {
                @Override
                public void onCompleted() {
                    promotionMoreView.hideProgress();
                }

                @Override
                public void onError(Throwable e) {
                    promotionMoreView.showError((Exception) e);
                    promotionMoreView.hideProgress();
                }

                @Override
                public void onNext(PromotionMoreBean promotionMoreBean) {
                    promotionMoreView.getPromotionMore(promotionMoreBean);
                }

                @Override
                public void onStart() {
                    super.onStart();
                    promotionMoreView.showProgress();
                }
            });
        }
    }
}
